//定义状态的方法
import { handleActions } from "redux-actions";
//操作状态的类型
import { GET_TATOL_TYPE } from "../types.js";

import _ from "lodash"

// 初始化商品类型数据
const initData = {
    curPage: 1,
    eachPage: 15,
    total: 0,
    maxPage: 0,
    rows: []
}


// 创建reducer
export const totalType = handleActions({
    //state 为当前的初始值,payload 是hoock内dispach触发reducder内传来的参数
    [GET_TATOL_TYPE]: (state, { payload }) => {
      
        const {   total,
            rows,
            maxPage, } = payload 
       // data将state内有相同数据的的覆盖掉 
        return _.assign({},state,{
            total,
            rows,
            maxPage,
        })
       
       
    }

}, initData);